<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //1、Set的定义,唯一性
        var s1=new Set();  //空集合
        var s2=new Set(["刘德华","张学友","成龙","刘德华"]);

        //2、添加元素
        s1.add("tom");
        s1.add("jack");
        s1.add({name:"rose"});
        s1.add(9988);
        s1.add(9988);

        //3、获得集合的大小
        console.log(s1.size);

        //4、删除元素
        s1.delete("tom");
        s1.delete({name:"rose"});  //引用类型

        //5、清空
        s1.clear();

        //6、某个元素是否存在集合中
        console.log(s2.has("刘德华"));
        console.log(s2.has("张果"));

        console.log(s1);

        console.log(s2);
    </script>
</body>
</html>